const vm = new Vue({
  el: "#app",
  data: function () {
    return {
      titleValue: "",
      departTitleValue: "",
      nameValue: "",
      passwdValue: "",
      ageValue: "",
      timeValue: "",
      salaryValue: "",
      businessnameValue: "",
      businesstimeValue:"",
      priceValue:"",
      customerValue:"",
      phoneValue:"",
      userValue: '',
      passValue: '',
      confirmValue: '',
    };
  },
  computed: {
    isUser() {
       return !this.userValue.trim()
    },
    isPassEmpty() {
       return !this.passValue.trim()
    },
    isConfirmEmpty() {
       return !this.confirmValue.trim()
    },
    isBusinessName() {
      return !this.businessnameValue.trim()
    },
    isBusinessTime() {
      return !this.businesstimeValue.trim()
    },
    isPrice() {
      return !this.priceValue.trim()
    },
    isCustomer() {
      return !this.customerValue.trim()
    },
    isPhone() {
      return !this.phoneValue.trim()
    },
    isTitle() {
      return !this.titleValue.trim();
    },
    isDepartTitle() {
      return !this.departTitleValue.trim();
    },
    isName() {
      return !this.nameValue.trim()
    },
    isPasswd() {
      return !this.passwdValue.trim()
    },
    isAge() {
      return !this.ageValue.trim()
    },
    isTime() {
      return !this.timeValue.trim()
    },
    isSalary() {
      return !this.salaryValue.trim()
    }
  },
  methods: {
    businessnameChange() {
      this.isBusinessName;
    },
    businesstimeChange() {
      this.isBusinessTime;
    },
    priceChange() {
      this.isPrice;
    },
    customerChange() {
      this.isCustomer;
    },
    phoneChange() {
      this.isPhone;
    },
    titleBlur() {
      this.isTitle;
    },
    updateTitleBlur() {
      this.isDepartTitle;
    },
    nameChange() {
      this.isName;
    },
    passwdChange() {
      this.isPasswd;
    },
    ageChange() {
      this.isAge;
    },
    timeChange() {
      this.isTime;
    },
    salaryChange() {
      this.isSalary;
    },
    userBlur() {
          if (this.isUser) {
            alert("用户名不能为空 !")
          }else if (this.userValue.length < 4 || this.userValue.length > 8) {
            alert("用户名长度范围要在 4 ~ 8 之间 ! ")
            this.userValue = ''
          }
        },
        passBlur() {
          if (this.isPassEmpty) {
            alert("密码不能为空 ! ")
          }else if (this.passValue.length < 6 || this.passValue.length > 16) {
            alert("密码长度范围要在 6 ~ 16 之间 ! ")
            this.passValue = ''
          }
        },
        confirmBlur() {
          if (this.isConfirmEmpty) {
            alert("请确认密码 !")
          }else if (this.passValue != this.confirmValue) {
            alert("密码不一致! ")
            this.confirmValue = ''
          }
        }
  },
});
